<template>
  <div class="product">
    <h3>标题：{{ proname }}</h3>
    <p>价格:{{ proprice }}元一根</p>
    <p>描述:{{ desc }} <button @click="bargin">砍一刀</button></p>
  </div>
</template>

<script>
export default {
  // 这里的name 和 注册的名字要统一，推荐使用大驼峰
  name: 'MyProduct',
  props: ['proname', 'proprice', 'id', 'desc'],
  methods: {
    bargin() {
      this.$emit('sayPrice', this.id, 10)
    },
  },
  data() {
    return {}
  },
}
</script>

<style lang="less" scoped>
.product {
  width: 400px;
  border: 3px solid #000;
  border-radius: 5px;
  margin: 10px;
  padding: 0 20px;
}
</style>
